var api = require('../../utils/api.js')

Page({
    data: {
        list: [],
        usertype:'user',
        wait_order_count:0
    },
    onLoad() {
      //加载订单列表数据
      api.get({
        url: 'portal/user/worklist?statu=1',
        success: data => {
          if (data.code == 1) {
            this.setData({
              wait_order_count: data.data.length
            })
          }
        }
      })
    },
    onShow(){
      var that=this;
      wx.getStorage({
        key: 'user',
        success: (res) => {
          that.setData({ user: res.data });
          console.log(res.data)
        }
      })
    },
    switch_user:function(e){
      var that=this;
        wx.showModal({
          title: '',
          content: '请选择您的身份',
          confirmText: "工人端",
          cancelText: "用户端",
          success: function (res) {
            if (res.confirm) {
              var usertype="worker"
            } else {
              var usertype = "user"
            }
            that.data.user['usertype'] = usertype
            that.setData({ usertype: usertype})
            wx.setStorage({
              key: "user",
              data: that.data.user
            })
          }
        });
    }
});